package com.augurit.gzcgwsp.csdlwj.convert;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.dozer.DozerBeanMapper;

import com.augurit.common.util.lang.DateUtils;
import com.augurit.gzcgwsp.csdlwj.entity.YwSrDlwjSqb;
import com.augurit.gzcgwsp.csdlwj.web.form.YwSrDlwjSqbForm;
import com.augurit.gzcgwsp.hwgz.web.form.YwHwShSqbForm;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComQyxxForm;

public class YwSrDlwjSqbConvertor {
	public static YwSrDlwjSqbForm convertVoToForm(YwSrDlwjSqb entity) {
		if(entity != null) {
			YwSrDlwjSqbForm form = new YwSrDlwjSqbForm();
			form.setId(entity.getId());
			form.setQyid(entity.getQyid());
			form.setJsdw(entity.getSqdw());
			form.setJsdwAddress(entity.getJsdwAddress());
			form.setJsdwTel(entity.getJsdwTel());
			form.setFddbr(entity.getFddbr());
			form.setFddbrLxr(entity.getFddbrLxr());
			form.setSgdw(entity.getSgdw());
			form.setSgdwAddress(entity.getSgdwAddress());
			form.setSgdwTel(entity.getSgdwTel());
			form.setAqfzr(entity.getAqfzr());
			form.setAqfzrLxr(entity.getAqfzrLxr());
			form.setPzwh(entity.getPzwh());
			form.setLmqsld(entity.getLmqsld());
			form.setWjdlq(entity.getWjdlq());
			form.setDlglbm(entity.getDlglbm());
			form.setDlqkLqlLength(entity.getDlqkLqlLength());
			form.setDlqkLqlWidth(entity.getDlqkLqlWidth());
			form.setDlqkSnlLength(entity.getDlqkSnlLength());
			form.setDlqkSnlWidth(entity.getDlqkSnlWidth());
			form.setDlqkNjlLength(entity.getDlqkNjlLength());
			form.setDlqkNjlWidth(entity.getDlqkNjlWidth());
			form.setDlqkRxdLength(entity.getDlqkRxdLength());
			form.setDlqkRxdWidth(entity.getDlqkRxdWidth());
			form.setDlqkCsLength(entity.getDlqkCsLength());
			form.setDlqkCsWidth(entity.getDlqkCsWidth());
			form.setDlqkNl(entity.getDlqkNl());
			form.setDlqkMssd(entity.getDlqkMssd());
			form.setDlqkGjsl(entity.getDlqkGjsl());
			form.setKwsjStart(entity.getKwsjStart());
			form.setKwsjEnd(entity.getKwsjEnd());
			form.setWjlb(entity.getWjlb());
			form.setJtbmyj(entity.getJtbmyj());
			form.setXcglr(entity.getXcglr());
			form.setFzr(entity.getFzr());
			form.setTbrq(entity.getTbrq());
			form.setAcceptNo(entity.getAcceptNo());
			form.setYsl(entity.getYsl());
			form.setJarq(entity.getJarq());
			form.setLarq(entity.getLarq());
			form.setIsycbl(entity.getIsycbl());
			form.setSqdw(entity.getSqdw());
			form.setCbyw(entity.getCbyw());
			form.setJbrxm(entity.getJbrxm());
			form.setJar(entity.getJar());
			form.setSarq(entity.getSarq());
			return form;
		}else
			return null;
	}
	
	public static void convertFormToVo(YwSrDlwjSqbForm form, YwSrDlwjSqb entity) {
		if(entity != null && form != null) {
			entity.setId(form.getId());
			entity.setQyid(form.getQyid());
			if(form.getJsdw() != null && form.getJsdw().trim().length() > 0)
				entity.setJsdw(form.getSqdw().trim());
			if(form.getJsdwAddress() != null && form.getJsdwAddress().trim().length() > 0)
				entity.setJsdwAddress(form.getJsdwAddress().trim());
			if(form.getJsdwTel() != null && form.getJsdwTel().trim().length() > 0)
				entity.setJsdwTel(form.getJsdwTel().trim());
			if(form.getFddbr() != null && form.getFddbr().trim().length() > 0)
				entity.setFddbr(form.getFddbr().trim());
			if(form.getFddbrLxr() != null && form.getFddbrLxr().trim().length() > 0)
				entity.setFddbrLxr(form.getFddbrLxr().trim());
			if(form.getSgdw() != null && form.getSgdw().trim().length() > 0)
				entity.setSgdw(form.getSgdw().trim());
			if(form.getSgdwAddress() != null && form.getSgdwAddress().trim().length() > 0)
				entity.setSgdwAddress(form.getSgdwAddress().trim());
			if(form.getSgdwTel() != null && form.getSgdwTel().trim().length() > 0)
				entity.setSgdwTel(form.getSgdwTel().trim());
			if(form.getAqfzr() != null && form.getAqfzr().trim().length() > 0)
				entity.setAqfzr(form.getAqfzr().trim());
			if(form.getAqfzrLxr() != null && form.getAqfzrLxr().trim().length() > 0)
				entity.setAqfzrLxr(form.getAqfzrLxr().trim());
			if(form.getPzwh() != null && form.getPzwh().trim().length() > 0)
				entity.setPzwh(form.getPzwh().trim());
			if(form.getLmqsld() != null && form.getLmqsld().trim().length() > 0)
				entity.setLmqsld(form.getLmqsld().trim());
			if(form.getWjdlq() != null && form.getWjdlq().trim().length() > 0)
				entity.setWjdlq(form.getWjdlq().trim());
			if(form.getDlglbm() != null && form.getDlglbm().trim().length() > 0)
				entity.setDlglbm(form.getDlglbm().trim());
			if(form.getDlqkLqlLength() != null && form.getDlqkLqlLength().trim().length() > 0)
				entity.setDlqkLqlLength(form.getDlqkLqlLength().trim());
			if(form.getDlqkLqlWidth() != null && form.getDlqkLqlWidth().trim().length() > 0)
				entity.setDlqkLqlWidth(form.getDlqkLqlWidth().trim());
			if(form.getDlqkSnlLength() != null && form.getDlqkSnlLength().trim().length() > 0)
				entity.setDlqkSnlLength(form.getDlqkSnlLength().trim());
			if(form.getDlqkSnlWidth() != null && form.getDlqkSnlWidth().trim().length() > 0)
				entity.setDlqkSnlWidth(form.getDlqkSnlWidth().trim());
			if(form.getDlqkNjlLength() != null && form.getDlqkNjlLength().trim().length() > 0)
				entity.setDlqkNjlLength(form.getDlqkNjlLength().trim());
			if(form.getDlqkNjlWidth() != null && form.getDlqkNjlWidth().trim().length() > 0)
				entity.setDlqkNjlWidth(form.getDlqkNjlWidth().trim());
			if(form.getDlqkRxdLength() != null && form.getDlqkRxdLength().trim().length() > 0)
				entity.setDlqkRxdLength(form.getDlqkRxdLength().trim());
			if(form.getDlqkRxdWidth() != null && form.getDlqkRxdWidth().trim().length() > 0)
				entity.setDlqkRxdWidth(form.getDlqkRxdWidth().trim());
			if(form.getDlqkCsLength() != null && form.getDlqkCsLength().trim().length() > 0)
				entity.setDlqkCsLength(form.getDlqkCsLength().trim());
			if(form.getDlqkCsWidth() != null && form.getDlqkCsWidth().trim().length() > 0)
				entity.setDlqkCsWidth(form.getDlqkCsWidth().trim());
			if(form.getDlqkNl() != null && form.getDlqkNl().trim().length() > 0)
				entity.setDlqkNl(form.getDlqkNl().trim());
			if(form.getDlqkMssd() != null && form.getDlqkMssd().trim().length() > 0)
				entity.setDlqkMssd(form.getDlqkMssd().trim());
			if(form.getDlqkGjsl() != null && form.getDlqkGjsl().trim().length() > 0)
				entity.setDlqkGjsl(form.getDlqkGjsl().trim());
			entity.setKwsjStart(form.getKwsjStart());
			entity.setKwsjEnd(form.getKwsjEnd());
			if(form.getWjlb() != null && form.getWjlb().trim().length() > 0)
				entity.setWjlb(form.getWjlb().trim());
			if(form.getJtbmyj() != null && form.getJtbmyj().trim().length() > 0)
				entity.setJtbmyj(form.getJtbmyj().trim());
			if(form.getXcglr() != null && form.getXcglr().trim().length() > 0)
				entity.setXcglr(form.getXcglr().trim());
			if(form.getFzr() != null && form.getFzr().trim().length() > 0)
				entity.setFzr(form.getFzr().trim());
			entity.setTbrq(form.getTbrq());
			if(form.getAcceptNo() != null && form.getAcceptNo().trim().length() > 0)
				entity.setAcceptNo(form.getAcceptNo().trim());
			entity.setYsl(form.getYsl());
			entity.setJarq(form.getJarq());
			entity.setLarq(form.getLarq());
			if(form.getIsycbl() != null && form.getIsycbl().trim().length() > 0)
				entity.setIsycbl(form.getIsycbl().trim());
			if(form.getSqdw() != null && form.getSqdw().trim().length() > 0)
				entity.setSqdw(form.getSqdw().trim());
			if(form.getCbyw() != null && form.getCbyw().trim().length() > 0)
				entity.setCbyw(form.getCbyw().trim());
			if(form.getJbrxm() != null && form.getJbrxm().trim().length() > 0)
				entity.setJbrxm(form.getJbrxm().trim());
			if(form.getJar() != null && form.getJar().trim().length() > 0)
				entity.setJar(form.getJar().trim());
			entity.setSarq(form.getSarq());
		}
	}
	
	public static List<YwSrDlwjSqbForm> convertVoListToFormList(List<YwSrDlwjSqb> ywSrDlwjSqbList) {
		if(ywSrDlwjSqbList != null && ywSrDlwjSqbList.size() > 0) {
			List<YwSrDlwjSqbForm> ywSrDlwjSqbFormList = new ArrayList();
			for(int i=0; i<ywSrDlwjSqbList.size(); i++) {
				ywSrDlwjSqbFormList.add(convertVoToForm(ywSrDlwjSqbList.get(i)));
			}
			return ywSrDlwjSqbFormList;
		}
		return null;
	}
	
	public static List<Map> convertVoListToMapList(List<YwSrDlwjSqb> ywSrDlwjSqbList) {
		if(ywSrDlwjSqbList != null && ywSrDlwjSqbList.size() > 0) {
			List<Map> mapList = new ArrayList();
			for(int i=0; i<ywSrDlwjSqbList.size(); i++) {
				YwSrDlwjSqb entity = ywSrDlwjSqbList.get(i);
				Map<String, String> map = new HashMap();

				map.put("id", entity.getId() == null ? "" : entity.getId().toString());
				map.put("qyid", entity.getQyid() == null ? "" : entity.getQyid().toString());
				map.put("jsdw", entity.getJsdw());
				map.put("jsdwAddress", entity.getJsdwAddress());
				map.put("jsdwTel", entity.getJsdwTel());
				map.put("fddbr", entity.getFddbr());
				map.put("fddbrLxr", entity.getFddbrLxr());
				map.put("sgdw", entity.getSgdw());
				map.put("sgdwAddress", entity.getSgdwAddress());
				map.put("sgdwTel", entity.getSgdwTel());
				map.put("aqfzr", entity.getAqfzr());
				map.put("aqfzrLxr", entity.getAqfzrLxr());
				map.put("pzwh", entity.getPzwh());
				map.put("lmqsld", entity.getLmqsld());
				map.put("wjdlq", entity.getWjdlq());
				map.put("dlglbm", entity.getDlglbm());
				map.put("dlqkLqlLength", entity.getDlqkLqlLength());
				map.put("dlqkLqlWidth", entity.getDlqkLqlWidth());
				map.put("dlqkSnlLength", entity.getDlqkSnlLength());
				map.put("dlqkSnlWidth", entity.getDlqkSnlWidth());
				map.put("dlqkNjlLength", entity.getDlqkNjlLength());
				map.put("dlqkNjlWidth", entity.getDlqkNjlWidth());
				map.put("dlqkRxdLength", entity.getDlqkRxdLength());
				map.put("dlqkRxdWidth", entity.getDlqkRxdWidth());
				map.put("dlqkCsLength", entity.getDlqkCsLength());
				map.put("dlqkCsWidth", entity.getDlqkCsWidth());
				map.put("dlqkNl", entity.getDlqkNl());
				map.put("dlqkMssd", entity.getDlqkMssd());
				map.put("dlqkGjsl", entity.getDlqkGjsl());
				map.put("kwsjStart", DateUtils.dateTimeToString(entity.getKwsjStart(), "yyyy-MM-dd"));
				map.put("kwsjEnd", DateUtils.dateTimeToString(entity.getKwsjEnd(), "yyyy-MM-dd"));
				map.put("wjlb", entity.getWjlb());
				map.put("jtbmyj", entity.getJtbmyj());
				map.put("xcglr", entity.getXcglr());
				map.put("fzr", entity.getFzr());
				map.put("tbrq", DateUtils.dateTimeToString(entity.getTbrq(), "yyyy-MM-dd"));
				map.put("acceptNo", entity.getAcceptNo());
				map.put("ysl", entity.getYsl() == null ? "" : entity.getYsl().toString());
				map.put("jarq", DateUtils.dateTimeToString(entity.getJarq(), "yyyy-MM-dd"));
				map.put("larq", DateUtils.dateTimeToString(entity.getLarq(), "yyyy-MM-dd"));
				map.put("isycbl", entity.getIsycbl());
				map.put("sqdw", entity.getSqdw());
				map.put("cbyw", entity.getCbyw());
				map.put("jbrxm", entity.getJbrxm());
				map.put("jar", entity.getJar());
				map.put("sarq", DateUtils.dateTimeToString(entity.getSarq(), "yyyy-MM-dd"));
				
				mapList.add(map);
			}
			return mapList;
		}
		return null;
	}
	
	public static List<YwSrDlwjSqb> convertFormListToVoList(List<YwSrDlwjSqbForm> ywSrDlwjSqbFormList) {
		if(ywSrDlwjSqbFormList != null && ywSrDlwjSqbFormList.size() > 0) {
			List<YwSrDlwjSqb> ywSrDlwjSqbList = new ArrayList();
			for(int i=0; i<ywSrDlwjSqbFormList.size(); i++) {
				YwSrDlwjSqb ywSrDlwjSqb = new YwSrDlwjSqb();
				convertFormToVo(ywSrDlwjSqbFormList.get(i), ywSrDlwjSqb);
				ywSrDlwjSqbList.add(ywSrDlwjSqb);
			}
			return ywSrDlwjSqbList;
		}
		return null;
	}
	
	public static void convertFormToQyxxForm(YwSrDlwjSqbForm form, YwComQyxxForm qyxxForm) {
        if (form == null) return;
        if (qyxxForm == null) qyxxForm = new YwComQyxxForm();

        new DozerBeanMapper().map(form, qyxxForm);
        qyxxForm.setId(form.getQyid());
    }

    public static void convertQyxxFormToForm(YwComQyxxForm qyxxForm, YwSrDlwjSqbForm form) {
        if (qyxxForm == null) return;
        if (form == null) form = new YwSrDlwjSqbForm();
        
        new DozerBeanMapper().map(qyxxForm, form);
        form.setQyid(qyxxForm.getId());
    }
}